package com.wxq.digest1.conf;

import com.wxq.digest1.Digest;
import com.wxq.digest1.impl.Md5DigestImpl;
import com.wxq.digest1.impl.ShaDigestImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@AutoConfiguration
@EnableConfigurationProperties(Settings.class)
public class Config {
    @Bean
    @ConditionalOnProperty(prefix = "digest",name = "type",havingValue = "md5")
    public Digest md5Digest(){
        System.out.println("wxq md5");
        return new Md5DigestImpl();
    }
    @Bean
    @ConditionalOnProperty(prefix = "digest",name = "type",havingValue = "sha")
    public Digest shaDigest(){
        System.out.println("wxq sha");
        return new ShaDigestImpl();
    }
}
